﻿using UnityEngine;
using Core;

namespace Core
{
    public struct GetCoreData : IEventData
    {
        public CoreDataObject coreData;
    }

    public class ConfigSystem : EntitySystem, IAwake
    {
        public CoreDataObject coreData;

        public void Awake()
        {
            coreData = Resources.Load<CoreDataObject>($"{GameConst.CORE_DATA_PATH}");
            if (coreData == null)
            {
                Debug.LogError("游戏未初始化，请先点击工具栏的Client/Init后再运行");
                coreData = ScriptableObject.CreateInstance<CoreDataObject>();
            }
            Subscribe<GetCoreData>(GetCoreData);
        }

        private void GetCoreData(ref GetCoreData data)
        {
            data.coreData = coreData;
        }
    }
}
